//
//  TabBarViewController.m
//  yun
//
//  Created by xjm on 15/8/27.
//  Copyright (c) 2015年 yunzu. All rights reserved.
//

#import "MianTabBarViewController.h"
#import "ZJBaseNavControllerViewController.h"
#import "ZJLoginViewController.h"
@interface MianTabBarViewController ()
{
    NSTimer *timer;
}
@end

@implementation MianTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     self.delegate=self;
    [self configureTabBarController];
    NSNotificationCenter *notiCenter = [NSNotificationCenter defaultCenter];
    [notiCenter addObserver:self selector:@selector(receiveNotification:) name:@"tokenLose" object:nil];
    
    
}

//taken失效跳转
- (void)receiveNotification:(NSNotification *)noti{
    ZJLoginViewController* logController =[[ZJLoginViewController alloc]init];
    ZJBaseNavControllerViewController* nav=[[ZJBaseNavControllerViewController alloc]initWithRootViewController:logController];
    logController.modality=YES;
    [self presentViewController:nav animated:YES completion:nil];
}

- (void)configureTabBarController {
    
    //初始化首页
//    ZJHomeViewController *homeCtl = [[ZJHomeViewController alloc] init];
	ZXHomeViewController *homeCtl = [[ZXHomeViewController alloc]init];
	
    ZJBaseNavControllerViewController *homeNav = [[ZJBaseNavControllerViewController alloc] initWithRootViewController:homeCtl];
    //homeCtl.title = @"首页";
    homeCtl.tabBarItem.title = MyString(@"首页");
    homeCtl.tabBarItem.image = [UIImage imageNamed:@"icon_home_nor"];
    homeCtl.tabBarItem.selectedImage = [UIImage imageNamed:@"icon_home_pre"];

	//种福田活动
	ActivityViewController *avVc = [[ActivityViewController alloc]init];
	ZJBaseNavControllerViewController *navAc = [[ZJBaseNavControllerViewController alloc]initWithRootViewController:avVc];
	navAc.tabBarItem.title = MyString(@"种福田");
	navAc.tabBarItem.image = [UIImage imageNamed:@"icon_activity_nor"];
	navAc.tabBarItem.selectedImage = [UIImage imageNamed:@"icon_activity_pre"];
	

    //初始化分类
    ZJClassifyViewController *classifyCtl = [[ZJClassifyViewController alloc] init];
    ZJBaseNavControllerViewController *classifyNav = [[ZJBaseNavControllerViewController alloc] initWithRootViewController:classifyCtl];
    classifyCtl.title = MyString(@"分类");
    classifyCtl.tabBarItem.title = MyString(@"分类");
    classifyCtl.tabBarItem.image = [UIImage imageNamed:@"icon_category_nor"];
    classifyCtl.tabBarItem.selectedImage = [UIImage imageNamed:@"icon_category_pre"];

    
    //初始化购物车
    
    ZJShopCarViewController *carCtl = [[ZJShopCarViewController alloc] init];
    ZJBaseNavControllerViewController *carNav = [[ZJBaseNavControllerViewController alloc] initWithRootViewController:carCtl];
    carCtl.title = MyString(@"购物车");
    carCtl.tabBarItem.title = MyString(@"购物车");
    carCtl.tabBarItem.image = [UIImage imageNamed:@"icon_shopping_nor"];
    carCtl.tabBarItem.selectedImage = [UIImage imageNamed:@"icon_shopping_pre"];

  
    //初始化我的
    ZJMineViewController *mineCtl = [[ZJMineViewController alloc] init];
    ZJBaseNavControllerViewController *mineNav = [[ZJBaseNavControllerViewController alloc] initWithRootViewController:mineCtl];
    mineCtl.tabBarItem.title = MyString(@"我的");
    mineCtl.tabBarItem.image = [UIImage imageNamed:@"icon_me_nor"];
    mineCtl.tabBarItem.selectedImage = [UIImage imageNamed:@"icon_me_pre"];


    self.viewControllers = @[homeNav, navAc,classifyNav, carNav, mineNav];
    self.tabBar.tintColor = tableBarRedColor;
    self.tabBar.backgroundColor=[UIColor whiteColor];
    self.selectedIndex=0;
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    
}

@end
